<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *公告管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';

if($_RQ['op']=='list'){
	
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>3);	
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','price','ordersn','finishtime','paytime');
	$list=pdo_getslice('jy_weishop_order',$params,array($pindex,$psize),$total,$fields,'','createtime desc');
	if($list){
		$goodslist=array();
		foreach($list as $k=>&$v){
			$ordergoods=pdo_getall('jy_weishop_order_goods',array('orderid'=>$v['id']),array('goodsid','total','price'));
			$v['total']=0;
			foreach($ordergoods as &$gv){
				$goods=pdo_get('jy_weishop_goods',array('id'=>$gv['goodsid']),array('title','image'));
				$gv['title']=$goods['title'];
				$gv['image']=$goods['image'];
				$gv['ordersn']=$v['ordersn'];
				$gv['paytime']=date('Y-m-d H:i:s',$v['paytime']);
				$goodslist[] = $gv;
				$v['total'] +=$gv['total'];
			}
		}
	}
	$return['list']=$goodslist;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'list'=>array('data'=>'list','delall'=>false,'del_one'=>false,'edit'=>false,'list'=>array(
			array('name'=>'ordersn','title'=>'订单编号','type'=>'string'),
			array('name'=>'title','title'=>'商品名称','type'=>'string'),
			array('name'=>'image','title'=>'商品图片','type'=>'image'),
			array('name'=>'price','title'=>'单价','type'=>'string'),
			array('name'=>'total','title'=>'数量','type'=>'string'),
			array('name'=>'paytime','title'=>'成交时间','type'=>'string'),
		)),
	
	);

	$return['htmls']=$htmls;
	
	exi($return);
}
